import Vue from 'vue'
import Router from 'vue-router'

const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
Vue.use(Router)

export default new Router({
  mode: 'history',
  base: 'admin',
  routes: [
    { //网站首页
      path: '/home',
      name: 'home',
      alias: '',
      authName: 'home',
      whileRoute: true,
      txtName: '网站首页',
      component: {
        template: '<zh-home />'
      },
    },
    { // 通过二维码访问的资产页面，无需登陆权限
      path: '/asset-h5/:id',
      name: 'asset-h5',
      authName: 'h5',
      whileRoute: true,
      txtName: '资产信息',
      component: {
        template: '<zh-h5-asset />'
      },
    },

    {
      path: '/login',
      name: 'login',
      authName: 'login',
      whileRoute: true,
      txtName: '登录',
      component: {
        template: '<zh-login />'
      },
    },
    { // 登陆成功后，动态插入路由
      path: '/',
      authName: 'index',
      component: {
        template: '<zh-html />'
      },
      children: []
    },
    {
      // ai报告
      path: '/ai-report',
      name: 'ai-report',
      authName: 'report',
      whileRoute: true,
      txtName: 'ai报告',
      component: {
        template: '<zh-ai-report />'
      },
    },
  ]
})
